package Clothing.controller.statistics;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import Clothing.bean.request.statistics.StatisticsRequest;
import Clothing.bean.respose.statistics.StatisticsResponse;
import Clothing.service.statistics.StatisticsService;
import Clothing.util.ResultModel;

@Controller
@RequestMapping(value = "/Statistics")
public class StatisticsController {

    @Resource
    private StatisticsService statisticsService;
    
    @RequestMapping(value = "/statistics" , method = RequestMethod.POST)
    @ResponseBody
    public ResultModel statistics(@RequestBody StatisticsRequest request){
        ResultModel resultModel = new ResultModel();
        StatisticsResponse response = new StatisticsResponse();

        int result = statisticsService.statistics(request,response);
        switch (result) {
            case 0:
                response.setSuccess("0");
                break;
            case 1:
                response.setSuccess("1");
            default:
                break;
        }
        resultModel.setData(response);
        return resultModel;
    }
}
